package com.ym.medical.service.impl;


import com.ym.core.utils.tkmybatis.BaseSVImpl;
import com.ym.medical.dao.DoctorLabelDao;
import com.ym.medical.domain.entity.DoctorLabelEntity;
import com.ym.medical.domain.param.DoctorLabelParam;
import com.ym.medical.service.IDoctorLabelSV;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class DoctorLabelSVImpl extends BaseSVImpl<DoctorLabelEntity, DoctorLabelDao> implements IDoctorLabelSV {

    @Override
    public long save(DoctorLabelEntity doctorLabel) {
        this.insert(doctorLabel);
        return doctorLabel.getId();
    }


    @Override
    public DoctorLabelEntity findById(long doctorLabelId) {
        return this.selectById(doctorLabelId);
    }

    @Override
    public DoctorLabelEntity findByModel(DoctorLabelParam doctorLabelModel) {
        List<DoctorLabelEntity> doctorLabels = list(doctorLabelModel);
        return doctorLabels.isEmpty() ? null : doctorLabels.get(0);
    }

    @Override
    public List<DoctorLabelEntity> list(DoctorLabelParam doctorLabelModel) {
        return this.selectList(doctorLabelModel.covert());
    }

    /**
     * 标签id数组
     * @param doctId
     * @param s
     * @return
     */
    @Override
    public Long[] selectLabIds(Long doctId, String s) {
        return mapper.selectLabIds(doctId,s);
    }

    @Override
    public void insertLabels(List<DoctorLabelEntity> doctorLabels) {
        mapper.insertLabels(doctorLabels);
    }

    @Override
    public void batchInsert(List<DoctorLabelEntity> goods) {
        for (DoctorLabelEntity good : goods) {
            this.insert(good);
        }
    }
}
